package pers.hubb.enumeration.user;

import pers.hubb.enumeration.BaseEnum;

/**
 * @author hubb
 * @Description
 * @Date 2018/4/21 20:36
 */
public enum UserTypeEnum implements BaseEnum {
	//个人用户
	Person(1, "个人用户"),
	//企业用户
	Company(2, "企业用户"),
	//管理员
	ADMIN(3, "管理员");

	private int code;
	private String msg;

	UserTypeEnum(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	/**
	 * 根据code获取枚举
	 *
	 * @param code
	 * @return
	 */
	public static UserTypeEnum getEnumByCode(int code) {
		for(UserTypeEnum userTypeEnum : UserTypeEnum.values()) {
			if (userTypeEnum.getCode() == code) {
				return userTypeEnum;
			}
		}

		return null;
	}

	@Override
	public int getCode() {
		return code;
	}

	@Override
	public String getMsg() {
		return msg;
	}
}
